# -*- coding: utf-8 -*-

'''eof
name:未能获取烟草数据
code:MG_Failed_Obtain_Tobacco_Data
tableName:
columnName:
groups:数据质量
dependencies:YSDDH_BTM
type:常用指标
datasourceType:在线指标
description:
eof'''


import sys
import pandas as pd
import json

reload(sys)
sys.setdefaultencoding('utf-8')


def format_data():
    try:
        indent = json.loads(YSDDH_BTM[0]['data'])
        return indent if isinstance(indent, dict) and len(indent) > 0 else [{}]
    except:
        return [{}]


def MG_Failed_Obtain_Tobacco_Data():
    null_type_list = ['', None, 'null', 'Null', 'NULL', '/', ' ']
    try:
        btm = format_data()
        indent_list = btm["data"]["indent"]
        if isinstance(indent_list, list) and indent_list != [{}]:
            if len(indent_list) >= 1:
                return 0
            else:
                return 1
        else:
            return 1
    except:
        return 1


result = MG_Failed_Obtain_Tobacco_Data()
